package view;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFrame;

import model.State;

/**
 * Class to create the GUI for submitting a paper.
 * @author Sarah George
 * @version Autumn 2012
 */
@SuppressWarnings("serial")
public class NewPaperAction extends AbstractAction {

	/**
	 * Field to hold the current state of the system.
	 */
	private State my_state;

	/**
	 * Constructs a new paper action.
	 */
	public NewPaperAction(State the_state) {
		super("Submit new paper ...");
		putValue(Action.MNEMONIC_KEY, KeyEvent.VK_S);
		putValue(Action.SELECTED_KEY, true);
		my_state = the_state;
	}

	/**
	 * Method to create the JFrame and JPanel for submitting a paper.
	 * @param arg0 the action event that triggers this method.
	 */
	@Override
	public void actionPerformed(ActionEvent arg0) {
		JFrame new_paper_frame = new JFrame("Submit New Paper");
		NewPaperPanel npp = new NewPaperPanel(my_state, new_paper_frame);

		new_paper_frame.add(npp,BorderLayout.CENTER);
		new_paper_frame.setResizable(true); 
		new_paper_frame.pack();
		new_paper_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   
		new_paper_frame.setLocationRelativeTo(null);
		new_paper_frame.setVisible(true);
	}
}//End class new paper action.